package cn.itcast.hotel.listener;

import cn.itcast.hotel.constatnts.MqConstants;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HotellnsertOrupdatelistener {


    @Autowired
    private IHotelService hotelService;
    @RabbitListener(bindings=@QueueBinding(
            value= @Queue(MqConstants.HOTEL_INSERT_QUEUE),
            exchange = @Exchange(value=MqConstants.HOTEL_EXCHANGE,type = ExchangeTypes.DIRECT),
            key = MqConstants.HOTEL_INSERT_KEY
    ))
    public void receiveMsg(String hotelString){

        hotelService.saveOrUpdataetES(hotelString);
    }
}
